#include <scdl/parser/Symbol.hpp>

#include <cstdlib>
#include <cstring>
#include <iostream>

using std::cout;
using namespace scdl;

String::String()
        : string(0)
{
}

String::~String()
{
        if (string)
                delete[] string;
}

SymbolCategory String::getCategory()
{
        return CATEGORY_STRING;
}

void String::prettyPrint(bool verbose)
{
        if (string)
                cout << '"' << string << '"';
        else
                cout << "<null>";
}

void String::setValue(const char *str)
{
        if (string)
                delete[] string;

        int len = strlen(str);
        string = new char[len + 1];
        memcpy(string, str, len + 1);
}

const char *String::getValue()
{
        return string;
}
